package ru.arriah.servicedesk.bean;

import java.sql.ResultSet;
import ru.arriah.common.bean.GenericBean;

public class UserBean extends GenericBean {    
   
   private String firstName;
   private String middleName;
   private String lastName;
   private String login;
   private String password;
   private String rePassword;
   private String formName;
   private String status;
   protected String email;  

   public UserBean() {            
   }  
   
   /**
    * Create bean from table "user"
    * @param resultSet
    */
   public UserBean(ResultSet resultSet) {      
      fillFromResultSet(resultSet);          
   }
   
   /**
    * Create bean from table with alias
    * @param resultSet
    */
   public UserBean(ResultSet resultSet, String table) {      
       fillFromResultSet(resultSet, table);    
   }
         
   public void fillFromResultSet(
      ResultSet resultSet   
   ) {
      fillFromResultSet(resultSet, "user");     
   }
   
   public void fillFromResultSet(
      ResultSet resultSet,
      String table
   ) {
      try {
         setId(resultSet.getInt(table+".id"));
         setLogin(resultSet.getString(table+".login"));
         setPassword(resultSet.getString(table+".password"));
         setLastName(resultSet.getString(table+".lastname"));
         setFirstName(resultSet.getString(table+".firstname"));
         setMiddleName(resultSet.getString(table+".middlename"));
         setStatus(resultSet.getString(table+".status"));
         setEmail(resultSet.getString(table+".email"));
      } catch (Exception e) {
         // TODO: handle exception
      }      
   }

   public String getEmail() {
      return email;
   }

   public void setEmail(String email) {
      this.email = email;
   }
   
   public String getFormName() {
      return lastName+" "+firstName;
   }
   
   public void setFormName(String value) {
      //nop
   }

   public String getFirstName() {
      return firstName;
   }

   public void setFirstName(String firstName) {
      this.firstName = firstName;
   }

   public String getLastName() {
      return lastName;
   }

   public void setLastName(String lastName) {
      this.lastName = lastName;
   }

   public String getLogin() {
      return login;
   }

   public void setLogin(String login) {
      this.login = login;
   }

   public String getMiddleName() {
      return middleName;
   }

   public void setMiddleName(String middleName) {
      this.middleName = middleName;
   }

   public String getPassword() {
      return password;
   }

   public void setPassword(String password) {
      this.password = password;
   }

   public String getRePassword() {
      return rePassword;
   }

   public void setRePassword(String rePassword) {
      this.rePassword = rePassword;
   }
      
   public boolean isValid() {
      // TODO Auto-generated method stub
      return false;
   }

   public String getStatus() {
      return status;
   }

   public void setStatus(String status) {
      this.status = status;
   }

}
